//
//  ViewController.m
//  植物大战僵尸
//
//  Created by Roach on 16/6/6.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [self creatImageView];
    [self creatAnimationImage1];
    [self creatAnimationImage];
    [self creatAnimationImage2];
    [self creatAnimationImage3];
    [self creatAnimationImage4];
    [super viewDidLoad];
    
    
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)creatImageView {
    UIImage *image =  [UIImage imageNamed:@"BackGround.png"];
    
    UIImageView *backgroundImageView = [[UIImageView alloc]initWithImage:image];
    backgroundImageView.frame = [UIScreen mainScreen].bounds;
    [self.view addSubview:backgroundImageView];
    [backgroundImageView release];
}
// 普通僵尸
- (void)creatAnimationImage {
    
    UIImageView *jiangshi = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Zombie0.tiff"]];
    jiangshi.frame = CGRectMake(250, 150, 80, 120);
    [self.view addSubview:jiangshi];
    [jiangshi release];
    
    NSMutableArray *muarray = [NSMutableArray arrayWithCapacity:25];
    
    for (int i = 0; i <= 21; i ++) {
        
        NSString *name = [NSString stringWithFormat:@"Zombie%d.tiff", i];
        UIImage *animationImage = [UIImage imageNamed:name];
        
        [muarray addObject:animationImage];
    }
    
    jiangshi.animationImages = muarray;
    
    jiangshi.animationDuration = 1.5;
    
    [jiangshi startAnimating];
    
}
// 内个僵尸
- (void) creatAnimationImage1 {
    UIImageView *jiangshi1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Bzombie1.tiff"]];
    jiangshi1.frame = CGRectMake(250, 70, 80, 120);
    [self.view addSubview:jiangshi1];
    [jiangshi1 release];
    
    NSMutableArray *muarray1 = [NSMutableArray arrayWithCapacity:25];
    
    for (int i = 1; i <= 25; i ++) {
        
        NSString *name = [NSString stringWithFormat:@"Bzombie%d.tiff", i];
        UIImage *animationImage = [UIImage imageNamed:name];
        
        [muarray1 addObject:animationImage];
    }
    
    jiangshi1.animationImages = muarray1;
    
    jiangshi1.animationDuration = 1.5;
    
    [jiangshi1 startAnimating];
}
// 花
- (void) creatAnimationImage2 {
    UIImageView *hua = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"flower1.tiff"]];
    hua.frame = CGRectMake(70, 70, 70, 100);
    [self.view addSubview:hua];
    [hua release];
    
    NSMutableArray *muarray1 = [NSMutableArray arrayWithCapacity:18];
    
    for (int i = 1; i <= 18; i ++) {
        
        NSString *name = [NSString stringWithFormat:@"flower%d.tiff", i];
        UIImage *animationImage = [UIImage imageNamed:name];
        
        [muarray1 addObject:animationImage];
    }
    
    hua.animationImages = muarray1;
    
    hua.animationDuration = 1.5;
    
    [hua startAnimating];
}
// 瓜
- (void) creatAnimationImage3{
    UIImageView *gua = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gua1.tiff"]];
    gua.frame = CGRectMake(70, 170, 70, 100);
    [self.view addSubview:gua];
    [gua release];
    
    NSMutableArray *muarray1 = [NSMutableArray arrayWithCapacity:16];
    
    for (int i = 1; i <= 16; i ++) {
        
        NSString *name = [NSString stringWithFormat:@"gua%d.tiff", i];
        UIImage *animationImage = [UIImage imageNamed:name];
        
        [muarray1 addObject:animationImage];
    }
    
    gua.animationImages = muarray1;
    
    gua.animationDuration = 1.5;
    
    [gua startAnimating];
}
// 射手
- (void) creatAnimationImage4 {
    UIImageView *sheshou = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"plants.tiff"]];
    sheshou.frame = CGRectMake(30, 300, 120, 70);
    [self.view addSubview:sheshou];
    [sheshou release];
    
    NSMutableArray *muarray1 = [NSMutableArray arrayWithCapacity:9];
    
    for (int i = 1; i <= 9; i ++) {
        
        NSString *name = [NSString stringWithFormat:@"plants%d.tiff", i];
        UIImage *animationImage = [UIImage imageNamed:name];
        
        [muarray1 addObject:animationImage];
    }
    
    sheshou.animationImages = muarray1;
    
    sheshou.animationDuration = 1.5;
    
    [sheshou startAnimating];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
